package com.zm.devmag.util;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Random;

import org.apache.commons.lang3.StringUtils;
/**
 * 付款订单号
 */
public class TradeNo {
	/**
	 * @return 订单号
	 */
	public static long getTradeNo(){
		long tradeNo;
		Random r = new Random();
		Calendar c = Calendar.getInstance();
		int year = c.get(Calendar.YEAR);
		int month = c.get(Calendar.MONTH) + 1;
		int day = c.get(Calendar.DAY_OF_MONTH);
		int hour = c.get(Calendar.HOUR_OF_DAY);
		int minute = c.get(Calendar.MINUTE);
		int second = c.get(Calendar.SECOND);
		int ms = c.get(Calendar.MILLISECOND);
		tradeNo = (year%100) * 10000 + month * 100 + day;
		tradeNo = tradeNo * 1000000 + hour * 10000 + minute * 100 + second;
		tradeNo = ( tradeNo * 1000 + ms ) * 1000 + r.nextInt(1000);
		return tradeNo;
	}
	
	public static List<String> splitString(String reg,String str){
		if(!StringUtils.isEmpty(str)&&str.indexOf(reg)>=0){
			String[] strs = str.split(reg);
			List<String> strList = new ArrayList<String>();
			for(String temp : strs){
				if(!StringUtils.isEmpty(temp)){
					strList.add(temp);
				}
			}
			return strList;
		}else{
			return null;
		}
	}
}
